package SimpleTileProvider
{
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	public class SimpleTileProvider implements ILRTileProvider
	{
		public function SimpleTileProvider() { ; }		
		public function initialize(mgr:LRCommanderMgr):void { m_mgr = mgr; }

		private var m_mgr:LRCommanderMgr;
		
		private var m_prepared:Boolean = false;
		public function get prepared():Boolean { return m_prepared; }

		private var tileNumber:uint = 0;
		private var tiles:Array = new Array();
		
		public function prepareTiles(suggestedTileCount:uint):void
		{
			TraceManager.trace_msg(TraceManager.SIMPLE_PROVIDER, TraceManager.TL_MEDIUM, "SimpleTileProvider::prepareTiles" );
			
			// If we're already prepared, release the current set of tiles.

			if( m_prepared )
			{
				tiles.length = 0;
				tileNumber = 0;
			}

			// Generate the requested number of tiles, plus a few extra.
			
			for( var i:uint = 0; i < suggestedTileCount; i++ )
			{
				var tile:RectangleTile = new RectangleTile;
				tile.rectLabel.text = tileNumber.toString();
				tileNumber++;
		
				tile.rectColor.color = Math.round( Math.random()*0xFFFFFF );
				m_mgr.tileList.push( tile );
			}
			
			m_prepared = true;
		}
	}
}